import 'package:flutter/material.dart';

class ObjectUtils {
  static isNullDefault<T>(T data, T defaultValue) {
    return data == null ? defaultValue : data;
  }

  static isNullDefaultFormat<T>(
      T data, T defaultValue, dynamic onFormat(T data)) {
    return data == null ? defaultValue : onFormat(data);
  }

  /// [controllers] 是否可用
  static bool isControllerEnable(List<TextEditingController> controllers) {
    bool isEnable = true;
    for (final element in controllers) {
      if (element.text.isEmpty) {
        isEnable = false;
        break;
      }
    }
    return isEnable;
  }
}
